/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hiof.moraa.server.dao;

import com.hiof.moraa.mapping.TblTarget;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
 *
 * @author Bergy
 */
public class HibernateTargetDAOImp implements TargetDAO {

    private SessionFactory factory;

    public SessionFactory getFactory() {
        return factory;
    }

    public void setFactory(SessionFactory factory) {
        this.factory = factory;
    }

    @Override
    public List<TblTarget> getListOfTargetInOneRoute(int routeId) {
        Session session = factory.getCurrentSession();

        String hql = "from TblTarget target where target.tblRoute.id = :routeId ";
        Query query = session.createQuery(hql);
        query.setInteger("routeId", routeId);
        List<TblTarget> targets = query.list();
        return targets;
    }
}
